﻿var ProductOrder_MainStore;
var ProductOrder_MainGridPanel;
var ProductGridSelectRow;
var PrevRow;  //前一行
var myMask;
var ThisCellOleValue;
var EditCellValue;
var g_ProID = -1;
var hidProductOrderImgID;
var hidProductOrderImgOldValue;
var imgProductOrderImgID;
var CurrentEditPgId;
var isShowScrollBar = false;
var ProCode;
var ProName;

Ext.onReady(function() {

    Ext.QuickTips.init();
    // 本地加载图片代码
    Ext.BLANK_IMAGE_URL = strPath + 'extjs/resources/images/default/s.gif';

    document.getElementById("td_toupi_img1").style.height = (parent.Ext.get("ContentFrame").getHeight() - 298) / 2;
    document.getElementById("td_toupi_img2").style.height = parent.Ext.get("ContentFrame").getHeight() - 298 - Ext.get("td_toupi_img1").getHeight() + 2;
    document.getElementById("img_toupi_img1").style.height = Ext.get("td_toupi_img1").getHeight() - 6;
    document.getElementById("img_toupi_img2").style.height = Ext.get("td_toupi_img2").getHeight() - 4;

    //图片窗口
    winProductOrderImg = new Ext.Window({
        width: parent.Ext.get("ContentFrame").getWidth() - 60,
        height: parent.Ext.get("ContentFrame").getHeight() - 60,
        layout: 'fit',
        plain: true,
        constrain: true, // windows不超过浏览器
        autoScroll: 'true',
        closeAction: 'hide',
        modal: true,
        deferredRender: false,
        resizable: false,
        bodyStyle: 'padding:5px;',
        buttonAlign: 'center',
        contentEl: 'divProductOrderImg',
        bodyStyle: 'border-top:0;padding:2 2 2 2;background:#E5E2EE;',
        closeAction: 'hide',
        listeners: {
            hide: function(t) {
                if (document.getElementById(hidProductOrderImgID).value != hidProductOrderImgOldValue)
                    UpdateProductInfo("productadd", imgProductOrderImgID.replace('img_', ''), document.getElementById(hidProductOrderImgID).value);
            }
        }
    });

    g_ProID = GetParastr("pro_id"); //获取地址栏参数

    myMask = new Ext.LoadMask(Ext.get("divProductOrder_Main"), { msg: "Please wait..." });
    //myMask.show();
    // ProductOrder_Maingrid的选择列的事件
    var smProductOrder_MainModel = new Ext.grid.CheckboxSelectionModel({
        singleSelect: false,
        hidden: true,
        listeners: {
            rowselect: function(sm, row, rec) {
                ProductGridSelectRow = row;
                //选择列事件
            }
        }
    });

    // 设置获取生产单列表的地址
    var httpProxyProductOrder_Main = new Ext.data.HttpProxy({
        url: strPath + 'GGFW/DocumentsManage/ProductOrderCommand.fwf?Method=GetProductGrid'
    });
    // 生产单数据对应字段的读取方式
    var readerProxyProductOrder_Main = new Ext.data.JsonReader({
        root: 'Records',
        id: 'HWTransferItemID',
        totalProperty: 'totalCount',
        fields: [
         { name: 'pg_id' }
        , { name: 'kailiao_color_deep' }
        , { name: 'kailiao_color_middle' }
        , { name: 'kailiao_color_light' }
        , { name: 'kailiao_size' }
        , { name: 'paifa_id' }
        , { name: 'paifa_pf_size' }
        , { name: 'paifa_pm_size1' }
        , { name: 'paifa_pm_size2' }
        , { name: 'paifa_pm_size3' }
        , { name: 'paifa_remark' }
        , { name: 'paifa_ft_size' }
        , { name: 'juanfa_id' }
        , { name: 'juanfa_tiao_num' }
        , { name: 'juanfa_cun_num' }
        , { name: 'juanfa_tong' }
        , { name: 'juanfa_direction' }
        , { name: 'juanfa_add_num' }
        , { name: 'juanfa_remark' }
        ]
    });

    // 定义生产单数据源
    ProductOrder_MainStore = new Ext.data.Store({
        proxy: httpProxyProductOrder_Main,
        reader: readerProxyProductOrder_Main,
        remoteSort: true
    });


    //加载生产单
    ProductOrder_MainLoad();

    var ProductOrder_MainlistColumnModel = new Ext.grid.ColumnModel([
    	smProductOrder_MainModel,
	    { id: 'product_pro_id', header: "pro_id", align: 'center', sortable: false, hidden: true, dataIndex: 'product_pro_id' }
	    , { id: 'grid_id', header: '序', width: 30, align: 'center', sortable: false, renderer: renderGridID }
	    , { id: 'pg_id', header: "pg_id", align: 'center', sortable: false, hidden: true, dataIndex: 'pg_id' }
		 , { id: 'kailiao_color_deep', header: "深g", width: 107, align: 'center', sortable: false, dataIndex: 'kailiao_color_deep', editor: new Ext.form.TextField({
		     listeners: {
		         focus: function(t) {
		             EditCellValue = null; //本行更改值
		             ThisCellOleValue = t.value; //本行旧值
		             CurrentEditPgId = ProductOrder_MainGridPanel.getSelectionModel().getSelected().data.pg_id; //本行的PgID
		             PrevRow = ProductGridSelectRow;
		         },
		         blur: function(t) {
		             if (EditCellValue == null) {
		                 EditCellValue = t.getValue();
		             }
		             if (EditCellValue != ThisCellOleValue) {
		                 //UpdateProductGridCellValue('kailiao_color_deep', EditCellValue, CurrentEditPgId);
		                 CheckNumeralSlash('kailiao_color_deep', ThisCellOleValue, t.getValue(), PrevRow, ProductOrder_MainGridPanel, CurrentEditPgId);
		             }
		         }
		     }
		 })
		 }
        , { id: 'kailiao_color_middle', header: "中g", width: 107, align: 'center', sortable: false, dataIndex: 'kailiao_color_middle', editor: new Ext.form.TextField({
            listeners: {
                focus: function(t) {
                    EditCellValue = null; //本行更改值
                    ThisCellOleValue = t.value; //本行旧值
                    CurrentEditPgId = ProductOrder_MainGridPanel.getSelectionModel().getSelected().data.pg_id; //本行的PgID
                    PrevRow = ProductGridSelectRow;
                },
                blur: function(t) {
                    if (EditCellValue == null) {
                        EditCellValue = t.getValue();
                    }
                    if (EditCellValue != ThisCellOleValue) {
                        //UpdateProductGridCellValue('kailiao_color_middle', EditCellValue, CurrentEditPgId);
                        CheckNumeralSlash('kailiao_color_middle', ThisCellOleValue, t.getValue(), PrevRow, ProductOrder_MainGridPanel, CurrentEditPgId);
                    }
                }
            }
        })
        }
        , { id: 'kailiao_color_light', header: "浅g", width: 106, align: 'center', sortable: false, dataIndex: 'kailiao_color_light', editor: new Ext.form.TextField({
            listeners: {
                focus: function(t) {
                    EditCellValue = null; //本行更改值
                    ThisCellOleValue = t.value; //本行旧值
                    CurrentEditPgId = ProductOrder_MainGridPanel.getSelectionModel().getSelected().data.pg_id; //本行的PgID
                    PrevRow = ProductGridSelectRow;
                },
                blur: function(t) {
                    if (EditCellValue == null) {
                        EditCellValue = t.getValue();
                    }
                    if (EditCellValue != ThisCellOleValue) {
                        //UpdateProductGridCellValue('kailiao_color_light', EditCellValue, CurrentEditPgId);
                        CheckNumeralSlash('kailiao_color_light', ThisCellOleValue, t.getValue(), PrevRow, ProductOrder_MainGridPanel, CurrentEditPgId);
                    }
                }
            }
        })
        }
        , { id: 'kailiao_size', header: "开料尺寸", width: 140, align: 'center', sortable: false, dataIndex: 'kailiao_size', editor: new Ext.form.TextField({
            listeners: {
                focus: function(t) {
                    EditCellValue = null; //本行更改值
                    ThisCellOleValue = t.value; //本行旧值
                    CurrentEditPgId = ProductOrder_MainGridPanel.getSelectionModel().getSelected().data.pg_id; //本行的PgID
                    PrevRow = ProductGridSelectRow;
                },
                blur: function(t) {
                    if (EditCellValue == null) {
                        EditCellValue = t.getValue();
                    }
                    if (EditCellValue != ThisCellOleValue) {
                        UpdateProductGridCellValue('kailiao_size', EditCellValue, CurrentEditPgId);
                    }
                }
            }
        })
        }
        , { id: 'paifa_pf_size', header: "排发尺寸", width: 80, align: 'center', sortable: false, dataIndex: 'paifa_pf_size', editor: new Ext.form.TextField({
            listeners: {
                focus: function(t) {
                    EditCellValue = null; //本行更改值
                    ThisCellOleValue = t.value; //本行旧值
                    CurrentEditPgId = ProductOrder_MainGridPanel.getSelectionModel().getSelected().data.pg_id; //本行的PgID
                    PrevRow = ProductGridSelectRow;
                },
                blur: function(t) {
                    if (EditCellValue == null) {
                        EditCellValue = t.getValue();
                    }
                    if (EditCellValue != ThisCellOleValue) {
                        UpdateProductGridCellValue('paifa_pf_size', EditCellValue, CurrentEditPgId);
                    }
                }
            }
        })
        }
        , { id: 'paifa_pm_size1', header: "排码尺码1", width: 80, align: 'center', sortable: false, dataIndex: 'paifa_pm_size1', editor: new Ext.form.TextField({
            listeners: {
                focus: function(t) {
                    EditCellValue = null; //本行更改值
                    ThisCellOleValue = t.value; //本行旧值
                    CurrentEditPgId = ProductOrder_MainGridPanel.getSelectionModel().getSelected().data.pg_id; //本行的PgID
                    PrevRow = ProductGridSelectRow;
                },
                blur: function(t) {
                    if (EditCellValue == null) {
                        EditCellValue = t.getValue();
                    }
                    if (EditCellValue != ThisCellOleValue) {
                        //UpdateProductGridCellValue('paifa_pm_size1', EditCellValue, CurrentEditPgId);
                        CheckNumeral('paifa_pm_size1', ThisCellOleValue, t.getValue(), PrevRow, ProductOrder_MainGridPanel, CurrentEditPgId);
                    }
                }
            }
        })
        }
        , { id: 'paifa_pm_size2', header: "排码尺码2", width: 80, align: 'center', sortable: false, dataIndex: 'paifa_pm_size2', editor: new Ext.form.TextField({
            listeners: {
                focus: function(t) {
                    EditCellValue = null; //本行更改值
                    ThisCellOleValue = t.value; //本行旧值
                    CurrentEditPgId = ProductOrder_MainGridPanel.getSelectionModel().getSelected().data.pg_id; //本行的PgID
                    PrevRow = ProductGridSelectRow;
                },
                blur: function(t) {
                    if (EditCellValue == null) {
                        EditCellValue = t.getValue();
                    }
                    if (EditCellValue != ThisCellOleValue) {
                        //UpdateProductGridCellValue('paifa_pm_size2', EditCellValue, CurrentEditPgId);
                        CheckNumeral('paifa_pm_size2', ThisCellOleValue, t.getValue(), PrevRow, ProductOrder_MainGridPanel, CurrentEditPgId);
                    }
                }
            }
        })
        }
        , { id: 'paifa_pm_size3', header: "排码尺码3", width: 80, align: 'center', sortable: false, dataIndex: 'paifa_pm_size3', editor: new Ext.form.TextField({
            listeners: {
                focus: function(t) {
                    EditCellValue = null; //本行更改值
                    ThisCellOleValue = t.value; //本行旧值
                    CurrentEditPgId = ProductOrder_MainGridPanel.getSelectionModel().getSelected().data.pg_id; //本行的PgID
                    PrevRow = ProductGridSelectRow;
                },
                blur: function(t) {
                    if (EditCellValue == null) {
                        EditCellValue = t.getValue();
                    }
                    if (EditCellValue != ThisCellOleValue) {
                        //UpdateProductGridCellValue('paifa_pm_size3', EditCellValue, CurrentEditPgId);
                        CheckNumeral('paifa_pm_size3', ThisCellOleValue, t.getValue(), PrevRow, ProductOrder_MainGridPanel, CurrentEditPgId);
                    }
                }
            }
        })
        }
        , { id: 'paifa_remark', header: "备注", width: 130, align: 'center', sortable: false, dataIndex: 'paifa_remark', editor: new Ext.form.TextField({
            listeners: {
                focus: function(t) {
                    EditCellValue = null; //本行更改值
                    ThisCellOleValue = t.value; //本行旧值
                    CurrentEditPgId = ProductOrder_MainGridPanel.getSelectionModel().getSelected().data.pg_id; //本行的PgID
                    PrevRow = ProductGridSelectRow;
                },
                blur: function(t) {
                    if (EditCellValue == null) {
                        EditCellValue = t.getValue();
                    }
                    if (EditCellValue != ThisCellOleValue) {
                        UpdateProductGridCellValue('paifa_remark', EditCellValue, CurrentEditPgId);
                    }
                }
            }
        })
        }
        , { id: 'paifa_ft_size', header: "发条尺寸", width: 80, align: 'center', sortable: false, dataIndex: 'paifa_ft_size', editor: new Ext.form.TextField({
            listeners: {
                focus: function(t) {
                    EditCellValue = null; //本行更改值
                    ThisCellOleValue = t.value; //本行旧值
                    CurrentEditPgId = ProductOrder_MainGridPanel.getSelectionModel().getSelected().data.pg_id; //本行的PgID
                    PrevRow = ProductGridSelectRow;
                },
                blur: function(t) {
                    if (EditCellValue == null) {
                        EditCellValue = t.getValue();
                    }
                    if (EditCellValue != ThisCellOleValue) {
                        //UpdateProductGridCellValue('paifa_ft_size', EditCellValue, CurrentEditPgId);
                        CheckNumeral('paifa_ft_size', ThisCellOleValue, t.getValue(), PrevRow, ProductOrder_MainGridPanel, CurrentEditPgId);
                    }
                }
            }
        })
        }
        , { id: 'juanfa_tiao_num', header: "条", width: 80, align: 'center', sortable: false, dataIndex: 'juanfa_tiao_num', editor: new Ext.form.TextField({
            listeners: {
                focus: function(t) {
                    EditCellValue = null; //本行更改值
                    ThisCellOleValue = t.value; //本行旧值
                    CurrentEditPgId = ProductOrder_MainGridPanel.getSelectionModel().getSelected().data.pg_id; //本行的PgID
                    PrevRow = ProductGridSelectRow;
                },
                blur: function(t) {
                    if (EditCellValue == null) {
                        EditCellValue = t.getValue();
                    }
                    if (EditCellValue != ThisCellOleValue) {
                        //UpdateProductGridCellValue('juanfa_tiao_num', EditCellValue, CurrentEditPgId);
                        CheckNumeral('juanfa_tiao_num', ThisCellOleValue, t.getValue(), PrevRow, ProductOrder_MainGridPanel, CurrentEditPgId);
                    }
                }
            }
        })
        }
        , { id: 'juanfa_cun_num', header: "寸", width: 80, align: 'center', sortable: false, dataIndex: 'juanfa_cun_num', editor: new Ext.form.TextField({
            listeners: {
                focus: function(t) {
                    EditCellValue = null; //本行更改值
                    ThisCellOleValue = t.value; //本行旧值
                    CurrentEditPgId = ProductOrder_MainGridPanel.getSelectionModel().getSelected().data.pg_id; //本行的PgID
                    PrevRow = ProductGridSelectRow;
                },
                blur: function(t) {
                    if (EditCellValue == null) {
                        EditCellValue = t.getValue();
                    }
                    if (EditCellValue != ThisCellOleValue) {
                        //UpdateProductGridCellValue('juanfa_cun_num', EditCellValue, CurrentEditPgId);
                        CheckNumeral('juanfa_cun_num', ThisCellOleValue, t.getValue(), PrevRow, ProductOrder_MainGridPanel, CurrentEditPgId);
                    }
                }
            }
        })
        }
        , { id: 'juanfa_tong', header: "捲筒", width: 80, align: 'center', sortable: false, dataIndex: 'juanfa_tong', editor: new Ext.form.TextField({
            listeners: {
                focus: function(t) {
                    EditCellValue = null; //本行更改值
                    ThisCellOleValue = t.value; //本行旧值
                    CurrentEditPgId = ProductOrder_MainGridPanel.getSelectionModel().getSelected().data.pg_id; //本行的PgID
                    PrevRow = ProductGridSelectRow;
                },
                blur: function(t) {
                    if (EditCellValue == null) {
                        EditCellValue = t.getValue();
                    }
                    if (EditCellValue != ThisCellOleValue) {
                        UpdateProductGridCellValue('juanfa_tong', EditCellValue, CurrentEditPgId);
                    }
                }
            }
        })
        }
        , { id: 'juanfa_direction', header: "方向", width: 65, align: 'center', sortable: false, dataIndex: 'juanfa_direction', editor: new Ext.form.TextField({
            listeners: {
                focus: function(t) {
                    EditCellValue = null; //本行更改值
                    ThisCellOleValue = t.value; //本行旧值
                    CurrentEditPgId = ProductOrder_MainGridPanel.getSelectionModel().getSelected().data.pg_id; //本行的PgID
                    PrevRow = ProductGridSelectRow;
                },
                blur: function(t) {
                    if (EditCellValue == null) {
                        EditCellValue = t.getValue();
                    }
                    if (EditCellValue != ThisCellOleValue) {
                        UpdateProductGridCellValue('juanfa_direction', EditCellValue, CurrentEditPgId);
                    }
                }
            }
        })
        }
        , { id: 'juanfa_add_num', header: "条/支", width: 65, align: 'center', sortable: false, dataIndex: 'juanfa_add_num', editor: new Ext.form.TextField({
            listeners: {
                focus: function(t) {
                    EditCellValue = null; //本行更改值
                    ThisCellOleValue = t.value; //本行旧值
                    CurrentEditPgId = ProductOrder_MainGridPanel.getSelectionModel().getSelected().data.pg_id; //本行的PgID
                    PrevRow = ProductGridSelectRow;
                },
                blur: function(t) {
                    if (EditCellValue == null) {
                        EditCellValue = t.getValue();
                    }
                    if (EditCellValue != ThisCellOleValue) {
                        //UpdateProductGridCellValue('juanfa_add_num', EditCellValue, CurrentEditPgId);
                        CheckNumeral('juanfa_add_num', ThisCellOleValue, t.getValue(), PrevRow, ProductOrder_MainGridPanel, CurrentEditPgId);
                    }
                }
            }
        })
        }
        , { id: 'juanfa_remark', header: "备注", width: 132, align: 'center', sortable: false, dataIndex: 'juanfa_remark', editor: new Ext.form.TextField({
            listeners: {
                focus: function(t) {
                    EditCellValue = null; //本行更改值
                    ThisCellOleValue = t.value; //本行旧值
                    CurrentEditPgId = ProductOrder_MainGridPanel.getSelectionModel().getSelected().data.pg_id; //本行的PgID
                    PrevRow = ProductGridSelectRow;
                },
                blur: function(t) {
                    if (EditCellValue == null) {
                        EditCellValue = t.getValue();
                    }
                    if (EditCellValue != ThisCellOleValue) {
                        UpdateProductGridCellValue('juanfa_remark', EditCellValue, CurrentEditPgId);
                    }
                }
            }
        })
        }
	]);
    /**
    *描述 : 渲染列，鼠标移该单元格上面，显示完整的值
    *参数 : value：单元格的值；
    */
    function renderGridID(value, metadate, record, colIndex, rowIndex) {
        if (colIndex < 9)
            return '<div style="text-align:left;color:#969292;"><span>' + "0" + (colIndex + 1) + '</span></div>';
        else
            return '<div style="text-align:left;color:#969292;"><span>' + (colIndex + 1) + '</span></div>';
    }
    // 定义一个主GridPanel存放生产单列表信息
    ProductOrder_MainGridPanel = new Ext.grid.EditorGridPanel({
        id: "ProductOrder_MainGrid",
        height: parent.Ext.get("ContentFrame").getHeight() - 296,
        width: 1524,
        frame: false,
        loadMask: true,
        //        animCollapse: false,
        renderTo: "divProductOrder_Main",
        clicksToEdit: 1,
        stripeRows: true,
        store: ProductOrder_MainStore,
        cm: ProductOrder_MainlistColumnModel,
        sm: smProductOrder_MainModel,
        trackMouseOver: true,
        //        enableColumnHide: false,
        hideHeaders: true,
        border: false,
        listeners: {
            beforeedit: function(e) {
                var currRecord = e.record;
                if (currRecord.get("auditPass") == 1)
                    e.cancel = true;
            }
        }
    });

    // ProductOrder_Maingrid的选择列的事件
    var smMonitoringPositionModel = new Ext.grid.CheckboxSelectionModel({
        singleSelect: false,
        listeners: {
            rowselect: function(sm, row, rec) {
            }
        }
    });

    // 生产单信息加载
    function ProductOrder_MainLoad() {
        ProductOrder_MainStore.load({ params: { start: 0, limit: 500, pro_id: g_ProID }, callback: function(r) { InitBlankRow(); LoadProductInfo(); } });
    }

});

function InitBlankRow() {
    CheckScrollBar(ProductOrder_MainStore.getTotalCount());
    for (var i = 0; i < parseInt(((parent.Ext.get("ContentFrame").getHeight() - 296) - 1) / 21) - ProductOrder_MainStore.getTotalCount(); i++)
        AddGridRow(false);
}

function AddGridRow(showScrollBar) {
    ProductOrder_MainStore.add(new Ext.data.Record({ pg_id: 0 }));
    if (showScrollBar) {
        var c = ProductOrder_MainGridPanel.getView().scroller.dom;
        c.scrollTop = c.scrollHeight + 21;
        if (!isShowScrollBar)
            CheckScrollBar(ProductOrder_MainStore.data.items.length);
    }
}
function CheckScrollBar(gridCount) {
    if (gridCount > parseInt(((parent.Ext.get("ContentFrame").getHeight() - 296) - 1) / 21) && !isShowScrollBar) {
        isShowScrollBar = true;
        ProductOrder_MainGridPanel.getColumnModel().setColumnWidth(19, 115, true);
        ProductOrder_MainGridPanel.getView().refresh();
    }
}
//加载产品附加信息
function LoadProductInfo() {

    var strUrl = strPath + 'GGFW/DocumentsManage/ProductOrderCommand.fwf?Method=LoadProductInfo';

    Ext.Ajax.request({
        url: strUrl,
        method: 'POST',
        timeout: 60000, //设定超时时间为60秒
        params: {
            ProID: g_ProID
        },
        failure: function(response, options) {
            ReturnValue = Ext.MessageBox.alert("警告", "网络异常或登录过期，请重新登录！");
        },
        success: function(response, options) {
            var json = response.responseText;
            var obj = parseJsonResult(json);

            if (!obj.Success) {
                showMessage("错误！", "更新出现错误！请查看详细原因。", obj.Message);
            } else if (obj.data[0] != null) {
                document.getElementById("txt_pro_code").value = obj.data[0].code == null ? "" : obj.data[0].code;
                ProCode = document.getElementById("txt_pro_code").value;
                document.getElementById("txt_pro_pro_name").value = obj.data[0].pro_name == null ? "" : obj.data[0].pro_name;
                ProName = document.getElementById("txt_pro_pro_name").value;
                document.getElementById("txt_pro_reviewer").value = obj.data[0].reviewer == null ? "" : obj.data[0].reviewer;
                document.getElementById("txt_pro_designer").value = obj.data[0].designer == null ? "" : obj.data[0].designer;
                document.getElementById("txta_proadd_remark1").value = obj.data[0].remark1 == null ? "" : obj.data[0].remark1;
                document.getElementById("txta_proadd_remark2").value = obj.data[0].remark2 == null ? "" : obj.data[0].remark2;
                document.getElementById("txta_proadd_remark3").value = obj.data[0].remark3 == null ? "" : obj.data[0].remark3;
                document.getElementById("txta_proadd_wendu").value = obj.data[0].wendu == null ? "" : obj.data[0].wendu;
                document.getElementById("txta_proadd_date").value = obj.data[0].proadd_date == null ? "" : (obj.data[0].proadd_date.dateFormat("Y-m-d").substr(0, 4) <= 1900 ? "" : obj.data[0].proadd_date.dateFormat("Y-m-d"));
                document.getElementById("txta_proadd_gaotou").value = obj.data[0].gaotou == null ? "" : obj.data[0].gaotou;
                document.getElementById("txta_proadd_zaxiang").value = obj.data[0].zaxiang == null ? "" : obj.data[0].zaxiang;
                document.getElementById("txta_proadd_faxiang").value = obj.data[0].faxiang == null ? "" : obj.data[0].faxiang;
                document.getElementById("txt_proadd_toupi_guige").value = obj.data[0].toupi_guige == null ? "" : obj.data[0].toupi_guige;

                document.getElementById("hid_proadd_fx_zheng_image").value = obj.data[0].fx_zheng_image == null ? "" : obj.data[0].fx_zheng_image;
                document.getElementById("hid_proadd_fx_fan_image").value = obj.data[0].fx_fan_image == null ? "" : obj.data[0].fx_fan_image;
                document.getElementById("img_fx_zheng_image").src = obj.data[0].fx_zheng_image == null ? "" : "../UploadFile/" + obj.data[0].fx_zheng_image;
                document.getElementById("img_fx_fan_image").src = obj.data[0].fx_fan_image == null ? "" : "../UploadFile/" + obj.data[0].fx_fan_image;

                document.getElementById("hid_proadd_toupi_img1").value = obj.data[0].toupi_img1 == null ? "" : obj.data[0].toupi_img1;
                document.getElementById("hid_proadd_toupi_img2").value = obj.data[0].toupi_img2 == null ? "" : obj.data[0].toupi_img2;
                document.getElementById("img_toupi_img1").src = obj.data[0].toupi_img1 == null ? "" : "../UploadFile/" + obj.data[0].toupi_img1;
                document.getElementById("img_toupi_img2").src = obj.data[0].toupi_img2 == null ? "" : "../UploadFile/" + obj.data[0].toupi_img2;

                document.getElementById("txt_bz_fawan").value = obj.data[0].fawan == null ? "" : obj.data[0].fawan;
                document.getElementById("txt_bz_saizhi").value = obj.data[0].saizhi == null ? "" : obj.data[0].saizhi;
                document.getElementById("txt_bz_zhitiao").value = obj.data[0].zhitiao == null ? "" : obj.data[0].zhitiao;
                document.getElementById("txt_bz_jiaodai").value = obj.data[0].jiaodai == null ? "" : obj.data[0].jiaodai;
                document.getElementById("txt_bz_zhixiang").value = obj.data[0].zhixiang == null ? "" : obj.data[0].zhixiang;
            }
        }
    });
}

//更新产品GRID单个字段
function UpdateProductGridCellValue(filedname, filevalue, pg_id) {

    var strUrl = strPath + 'GGFW/DocumentsManage/ProductOrderCommand.fwf?Method=UpdateProductGridfield';

    Ext.Ajax.request({
        url: strUrl,
        method: 'POST',
        timeout: 60000, //设定超时时间为60秒
        params: {
            PgID: pg_id,
            ProID: g_ProID,
            FieldName: filedname,
            FieldValue: filevalue
        },
        failure: function(response, options) {
            ReturnValue = Ext.MessageBox.alert("警告", "网络异常或登录过期，请重新登录！");
        },
        success: function(response, options) {
            var json = response.responseText;
            var obj = parseJsonResult(json);

            if (!obj.Success) {
                showMessage("错误！", "更新出现错误！请查看详细原因。", obj.Message);
            } else if (obj.data[0] != null) {
                ProductOrder_MainGridPanel.getStore().getAt(PrevRow).set('pg_id', obj.data[0].pg_id);
            }
        }
    });
}

//更新产品附加信息
function UpdateProductInfo(tab_name, filedname, filedvalue) {
    if (tab_name == "product" && filedname == "code" && filedvalue == "") {
        Ext.MessageBox.alert("提示", "<span style='font-weight:bold;'>编号信息</span>不能为空！</br>");
        document.getElementById("txt_pro_code").value = ProCode;
        return;
    }
    else if (tab_name == "product" && filedname == "code" && filedvalue != "")
        ProCode = filedvalue;
    else if (tab_name == "product" && filedname == "pro_name" && filedvalue == "") {
        Ext.MessageBox.alert("提示", "<span style='font-weight:bold;'>款名信息</span>不能为空！</br>");
        document.getElementById("txt_pro_pro_name").value = ProName;
        return;
    }
    else if (tab_name == "product" && filedname == "pro_name" && filedvalue != "")
        ProName = filedvalue;
    var strUrl = strPath + 'GGFW/DocumentsManage/ProductOrderCommand.fwf?Method=UpdateProductInfo';
    Ext.Ajax.request({
        url: strUrl,
        method: 'POST',
        timeout: 60000, //设定超时时间为60秒
        params: {
            ProID: g_ProID,
            TabName: tab_name,
            FiledName: filedname,
            FiledValue: filedvalue
        },
        failure: function(response, options) {
            ReturnValue = Ext.MessageBox.alert("警告", "网络异常或登录过期，请重新登录！");
        },
        success: function(response, options) {
            var json = response.responseText;
            var obj = parseJsonResult(json);

            if (!obj.Success) {
                showMessage("错误！", "更新出现错误！请查看详细原因。", obj.Message);
            }
        }
    });
}

//打开图片上传窗口
function showWinProductOrderImg(imgImgID, hidImgID) {
    imgProductOrderImgID = imgImgID;
    hidProductOrderImgID = hidImgID;
    hidProductOrderImgOldValue = document.getElementById(hidProductOrderImgID).value;
    document.getElementById("imgProductOrder").src = "../UploadFile/" + document.getElementById(hidProductOrderImgID).value;
    document.getElementById(imgProductOrderImgID).src = "../UploadFile/" + document.getElementById(hidProductOrderImgID).value;
    //document.getElementById("imgProductOrder").style.width = parent.Ext.get("ContentFrame").getWidth() - 80;
    document.getElementById("imgProductOrder").style.height = parent.Ext.get("ContentFrame").getHeight() - 160;
    //document.getElementById("fileQuick").style.width = parent.Ext.get("ContentFrame").getWidth() - 180;
    winProductOrderImg.setTitle("图片上传更新");
    document.getElementById("span_info").innerHTML = "请选择图片文件（*.jpg,*.gif,*.png,*.bmp)";
    controlShow('divProductOrderImg');
    winProductOrderImg.show();
}

function CloseWinProductOrderImg() {
    winProductOrderImg.hide();
}

